home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1980-02-25 | 3.6 KB | 134 lines |
- ' See the section marked with ******** in _LOADTEXT[] - it shows how to
- ' change the line length. See ******** in _DISPLAYPAGE[] to see how to
- ' set text position and font size.
- ' This variable sets the maximum number of pages in a document
- MXPAGES=120
-
- ' These variables set the page width and height
- PAGEWIDTH=78
- PAGEHEIGHT=24
-
- ' PAGE_START=Start in memory of the page
- ' PAGE_LEN =How many lines are in the page (always 15 unless at end of doc)
- Dim PAGE_START(MXPAGES),PAGE_LEN(MXPAGES)
- Global PAGEWIDTH,PAGEHEIGHT,PAGES,PAGE_START(),PAGE_LEN()
-
- F$=Fsel$("","","Select text file","")
- _LOADTEXT[F$,10]
-
- ' Picture is stored on screen 1
- F$=Fsel$("","","Select background piccy","")
- Load Iff F$,1
- Wait Vbl
-
- Screen Open 0,Screen Width,Screen Height,Screen Colour,Screen Mode
- Flash Off : Curs Off : Cls 0
- Get Palette 1
-
- Gr Writing 0
- Ink 15
- PAGE=1 : MK=0 : ESC=False
- Repeat
- If MK=1 and PAGE>1 Then Dec PAGE
- If MK=2 and PAGE<PAGES Then Inc PAGE
- _DISPLAYPAGE[PAGE]
- Repeat : Until Mouse Key=0
- Repeat
- MK=Mouse Key : ESC=Key State(69)
- Until ESC or MK
- Until ESC
-
- Erase All
-
- Edit
-
- Procedure _LOADTEXT[FILE$,BANK]
- ' Load text FILE$ into BANK
-
- Open In 1,FILE$ : SIZE=Lof(1) : Close 1
- Reserve As Work BANK,SIZE+4 : Bload FILE$,Start(BANK)
- SP=Start(BANK) : BNKEND=Start(BANK)+Length(BANK)
- L=0 : LASTSP=Start(BANK) : CHANGE=False
- Repeat
- C=Peek(SP)
- If C=13 Then Poke SP,10 : C=10
- If C<>10 Then Inc L Else L=0
- If C=32 Then LASTSP=SP : CHANGE=True
- If L>PAGEWIDTH
- If Not(CHANGE) : LASTSP=SP : End If
- Poke LASTSP,10 : L=0 : SP=LASTSP : CHANGE=False
- End If
- Inc SP
- Until SP>BNKEND
- SP=Start(BANK) : L=0 : PAGES=1 : OLDSP=SP-1
- Repeat
- C=Peek(SP)
- If C=10 or SP>=BNKEND
- Inc L
- If L=PAGEHEIGHT or SP>=BNKEND
- PAGE_START(PAGES)=OLDSP+1 : PAGE_LEN(PAGES)=L
- If L>0 : Inc PAGES : End If
- OLDSP=SP : L=0
- End If
- End If
- Inc SP
- Until SP>BNKEND
- Dec PAGES
- Dec PAGE_LEN(PAGES)
-
- End Proc
- Procedure _DISPLAYPAGE[PAGE]
- ' Display PAGE of text
-
- ' ***** Change these to where you want the text to start ************
- X=10 : Y=20
-
- ' ***** This variable is the height of the font in pixels ***********
- ' ***** topaz/8 was 8, so your new font, xxxx/9 would be size 9 *****
- SIZE=8
-
- Screen Copy 1 To 0
-
- SP=PAGE_START(PAGE)
- For L=1 To PAGE_LEN(PAGE)
- OLDSP=SP
- SP=Hunt(SP To SP+32*18,Chr$(10))+1
- If SP>0 Then Text X+0,Y+L*SIZE,Peek$(OLDSP,SP-OLDSP-1) Else Exit
- Next L
-
- End Proc
-
- Procedure _ADDEXTENSION[F$,X$]
- ' Adds file extension X$ to F$, eg F$="Data", X$="s", Param$="Data.s"
- ' Detects if it's already been added, and puts it in the case of X$...
- ' eg F$="Screen.iff" changes to "Screen.IFF" if X$="IFF"
-
- _FILENAME[F$] : FILENAM$=Param$
- X$=X$-"." : XPOS=Instr(FILENAM$,"."+X$)
- If XPOS<>Len(FILENAM$)-1-Len(X$)
- If XPOS=0 : XPOS=Instr(FILENAM$,".")
- If XPOS=0 : F$=F$+"."+X$
- Else F$=Left$(F$,XPOS+(Len(F$)-Len(FILENAM$)))+X$
- End If
- Else F$=Left$(F$,XPOS+1)+X$
- End If
- Else F$=Left$(F$,Len(F$)-Len(X$))+X$
- End If
-
- End Proc[F$]
- Procedure _BWINSTR[A$,C$]
- ' Backwards Instr command/procedure
- ' A$=Input string, C$=Search string
-
- X=Len(A$)
- While Mid$(A$,X,1)<>C$ and X>0 : Dec X : Wend
-
- End Proc[X]
- Procedure _FILENAME[F$]
- ' Get filename from pathname and filename F$
- ' eg. "DH0:Data/Pic.iff" would return "Pic.iff"
-
- _BWINSTR[F$,"/"] : SLASH=Param : _BWINSTR[F$,":"] : CLON=Param
- F$=Right$(F$,Len(F$)-Max(SLASH,CLON))
-
- End Proc[F$]